from selenium.webdriver.common.by import By
from selenium import webdriver
from time import sleep
from selenium.webdriver.support.ui import Select

# from day3.day import element

driver = webdriver.Chrome()
driver.get('http://192.168.1.37/ranzhi/www/sys/user-login.html')
username = driver.find_element(By.ID,'account')
username.send_keys('admin')
password = driver.find_element(By.ID,'password')
password.send_keys('123456')
login = driver.find_element(By.ID,'submit')
login.click()
# driver.get('http://192.168.1.37/ranzhi/www/sys/user-create.html')
sleep(5)
superadmin = driver.find_element(By.ID,'s-menu-superadmin')
superadmin.click()
sleep(5)
driver.switch_to.frame('iframe-superadmin')
addUser = driver.find_element(By.XPATH,'//*[@id="shortcutBox"]/div/div[1]/div/a')
addUser.click()
sleep(20)
# def send_id_keys(id,keys):
#     selected = driver.find_element(By.ID, id)
#     selected.send_keys(keys)
##########添加成员页面
account = driver.find_element(By.ID,'account')
account.send_keys('okk')
realname = driver.find_element(By.ID,'realname')
realname.send_keys('realokk')
sexM = driver.find_element(By.ID,'genderm')
genderf = driver.find_element(By.ID,'genderf')
sexM.click()
#1.
# driver.find_element(By.ID,"role").send_keys("研发")
# #2.
# driver.find_element(By.ID,"role").click()
# sleep(2)
# driver.find_element(By.XPATH,'//*[@id="role"]/option[2]').click()
# #3.
elements = driver.find_elements(By.TAG_NAME,"option")
for element in elements:
    if element.get_attribute("value")=="office":
        element.click()
sleep(3)
#4.
# roleSelect = Select(driver.find_element(By.ID,'role'))
# roleSelect.select_by_value('dev')
password1 = driver.find_element(By.ID,'password1')
password1.send_keys('123456')
sleep(2)
password2 = driver.find_element(By.ID,'password2')
password2.send_keys('123456')
sleep(2)
email = driver.find_element(By.ID,'email')
email.send_keys('123@qq.com')
submit = driver.find_element(By.ID,'submit')
submit.click()
sleep(10)
# driver.switch_to.parent_frame()
# icon1 = driver.find_element(By.XPATH,'//*[@id="s-menu-allapps"]/button')
# icon1.click()
# sleep(10)

